package com.dsteiner.widgets;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Timer;

import com.dsteiner.widgets.client.IJsUtil;
import com.dsteiner.widgets.client.ResponseHandler;
import com.dsteiner.widgets.client.Widgets.IAbsolutePanel;
import com.dsteiner.widgets.client.Widgets.IButton;
import com.dsteiner.widgets.client.Widgets.IFlexTable;
import com.dsteiner.widgets.client.Widgets.IFocusPanel;
import com.dsteiner.widgets.client.Widgets.IFocusWidget;
import com.dsteiner.widgets.client.Widgets.IFormPanel;
import com.dsteiner.widgets.client.Widgets.IHTML;
import com.dsteiner.widgets.client.Widgets.IHidden;
import com.dsteiner.widgets.client.Widgets.IImage;
import com.dsteiner.widgets.client.Widgets.IIndexedPanel;
import com.dsteiner.widgets.client.Widgets.ILazyWidget;
import com.dsteiner.widgets.client.Widgets.IListBox;
import com.dsteiner.widgets.client.Widgets.IPanel;
import com.dsteiner.widgets.client.Widgets.IPopupWidget;
import com.dsteiner.widgets.client.Widgets.IScrollPanel;
import com.dsteiner.widgets.client.Widgets.ISimplePanel;
import com.dsteiner.widgets.client.Widgets.ITimer;
import com.dsteiner.widgets.client.Widgets.IWidget;
import com.dsteiner.widgets.client.Widgets.MediaPicture;
import com.dsteiner.widgets.client.Widgets.PrefilledTextInput;
import com.dsteiner.widgets.client.Widgets.SelectionInput;
import com.dsteiner.widgets.client.Widgets.TextInput;
import com.dsteiner.widgets.client.Widgets.WidgetListener;
import com.google.gwt.event.dom.client.BlurHandler;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.ErrorHandler;
import com.google.gwt.event.dom.client.FocusHandler;
import com.google.gwt.event.dom.client.KeyDownHandler;
import com.google.gwt.event.dom.client.KeyPressHandler;
import com.google.gwt.event.dom.client.KeyUpHandler;
import com.google.gwt.event.dom.client.LoadHandler;
import com.google.gwt.event.dom.client.MouseDownHandler;
import com.google.gwt.event.dom.client.MouseMoveHandler;
import com.google.gwt.event.dom.client.MouseOutHandler;
import com.google.gwt.event.dom.client.MouseOverHandler;
import com.google.gwt.event.dom.client.MouseUpHandler;
import com.google.gwt.event.dom.client.MouseWheelHandler;
import com.google.gwt.event.logical.shared.ResizeHandler;
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.http.client.Request;
import com.google.gwt.http.client.RequestCallback;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.EventPreview;
import com.google.gwt.user.client.IncrementalCommand;
import com.google.gwt.user.client.WindowResizeListener;
import com.google.gwt.user.client.WindowScrollListener;
import com.google.gwt.user.client.Event.NativePreviewHandler;
import com.google.gwt.user.client.Window.ScrollHandler;
import com.google.gwt.user.client.ui.AbstractImagePrototype;
import com.google.gwt.user.client.ui.ChangeListener;
import com.google.gwt.user.client.ui.ChangeListenerCollection;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.ClickListenerCollection;
import com.google.gwt.user.client.ui.FocusListener;
import com.google.gwt.user.client.ui.FormHandler;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.KeyboardListener;
import com.google.gwt.user.client.ui.LoadListener;
import com.google.gwt.user.client.ui.LoadListenerCollection;
import com.google.gwt.user.client.ui.MouseListener;
import com.google.gwt.user.client.ui.MouseWheelListener;
import com.google.gwt.user.client.ui.PopupListener;
import com.google.gwt.user.client.ui.ScrollListener;
import com.google.gwt.user.client.ui.ScrollListenerCollection;
import com.google.gwt.user.client.ui.UIObject;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.user.client.ui.FormPanel.SubmitCompleteHandler;
import com.google.gwt.user.client.ui.FormPanel.SubmitHandler;
import com.google.gwt.user.client.ui.HasHorizontalAlignment.HorizontalAlignmentConstant;
import com.google.gwt.user.client.ui.HasVerticalAlignment.VerticalAlignmentConstant;

public class MockWidgets {
	
	
	public static class AbsolutePanelMock extends WidgetMock implements IAbsolutePanel{

		List<IWidget> widgets = new ArrayList<IWidget>();
		public void add(IWidget widget) {
			widgets.add(widget);
		}
		public void add(IWidget widget, int left, int top) {
		}
		public void add(Widget w) {
		}
		public void add(Widget widget, int left, int top) {
		}
		public void clear() {
		}
		public boolean contains(IWidget widget){
			return widgets.contains(widget);
		}
		public int getWidgetLeft(IWidget widget) {
			return 0;
		}
		public int getWidgetLeft(Widget widget) {
			return 0;
		}
		public int getWidgetTop(IWidget widget) {
			return 0;
		}
		public Iterator<Widget> iterator() {
			return null;
		}
		public void remove(IWidget widget) {
			// TODO Auto-generated method stub
			
		}
		public boolean remove(Widget w) {
			return false;
		}
		public void setWidgetPosition(IWidget widget, int left, int top) {
		}
		public void setWidgetPosition(Widget widget, int left, int top) {
		}
	}
	
	public static class AbstractImagePrototypeMock extends AbstractImagePrototype{
		private Image image;
		@Override
		public void applyTo(Image image) {
			this.image = image;
		}
		@Override
		public Image createImage() {
			return null;
		}
		@Override
		public String getHTML() {
			return null;
		}
		public Image getImage() {
			return image;
		}
	}
	
	public static class ButtonMock extends WidgetMock implements IButton{
		ClickListenerCollection clickListenerCollection = new ClickListenerCollection();
		private String text;
		private String html;
		private boolean enabled;
		public void addClickListener(ClickListener listener) {
			clickListenerCollection.add(listener);
		}

		public void addFocusListener(FocusListener listener) {
			// TODO Auto-generated method stub
			
		}

		public void addKeyboardListener(KeyboardListener listener) {
			// TODO Auto-generated method stub
			
		}

		public void fireClick(){
			clickListenerCollection.fireClick(null);
			for (ClickHandler clickHandler : clickHandlerCollection) {
				clickHandler.onClick(null);
			}
		}

		public String getHTML() {
			return html;
		}

		public int getTabIndex() {
			// TODO Auto-generated method stub
			return 0;
		}

		public String getText() {
			return text;
		}

		public boolean isAttached() {
			// TODO Auto-generated method stub
			return false;
		}

		public boolean isEnabled() {
			return enabled;
		}

		public void removeClickListener(ClickListener listener) {
			clickListenerCollection.remove(listener);
		}

		public void removeFocusListener(FocusListener listener) {
			// TODO Auto-generated method stub
			
		}

		public void removeKeyboardListener(KeyboardListener listener) {
			// TODO Auto-generated method stub
			
		}

		public void setAccessKey(char key) {
			// TODO Auto-generated method stub
			
		}

		public void setEnabled(boolean enabled) {
			this.enabled = enabled;
		}

		public void setFocus(boolean focused) {
			// TODO Auto-generated method stub
			
		}

		public void setHTML(String html) {
			this.html = html;
		}

		public void setTabIndex(int index) {
			// TODO Auto-generated method stub
			
		}
		public void setText(String text) {
			this.text = text;
		}

		List<ClickHandler> clickHandlerCollection = new ArrayList<ClickHandler>();
		public HandlerRegistration addClickHandler(ClickHandler handler) {
			clickHandlerCollection.add(handler);
			return null;
		}

		public void fireEvent(GwtEvent<?> event) {
		}

		List<KeyDownHandler> keyDownHandlers = new ArrayList<KeyDownHandler>();
		List<KeyUpHandler> keyUpHandlers = new ArrayList<KeyUpHandler>();
		List<KeyPressHandler> keyPressHandlers = new ArrayList<KeyPressHandler>();
		public HandlerRegistration addKeyDownHandler(KeyDownHandler handler) {
			keyDownHandlers.add(handler);
			return null;
		}

		public HandlerRegistration addKeyPressHandler(KeyPressHandler handler) {
			keyPressHandlers.add(handler);
			return null;
		}

		public HandlerRegistration addKeyUpHandler(KeyUpHandler handler) {
			keyUpHandlers.add(handler);
			return null;
		}

		public HandlerRegistration addFocusHandler(FocusHandler handler) {
			// TODO Auto-generated method stub
			return null;
		}

		public HandlerRegistration addBlurHandler(BlurHandler handler) {
			// TODO Auto-generated method stub
			return null;
		}
	}
	
	public static class FlexTableMock extends WidgetMock implements IFlexTable{

		public void add(IWidget widget) {
			
		}

		public void clear() {
		}

		public int getRowCount() {
			return 0;
		}

		public Widget getWidget(int column, int row) {
			// TODO Auto-generated method stub
			return null;
		}

		public void removeRow(int row) {
			// TODO Auto-generated method stub
			
		}

		public void setAlignment(int row, int column,
				HorizontalAlignmentConstant horizontalAlign,
				VerticalAlignmentConstant verticalAlign) {
			// TODO Auto-generated method stub
			
		}

		public void setWidget(int column, int row, IWidget rowWidget) {
		}

		public void add(Widget w) {
			// TODO Auto-generated method stub
			
		}

		public Iterator<Widget> iterator() {
			// TODO Auto-generated method stub
			return null;
		}

		public boolean remove(Widget w) {
			// TODO Auto-generated method stub
			return false;
		}

		public void setWidget(int column, int row, Widget widget) {
			// TODO Auto-generated method stub
			
		}

		public int getCellCount(int i) {
			// TODO Auto-generated method stub
			return 0;
		}
	}
	
	public static class FocusPanelMock extends WidgetMock implements IFocusPanel{

		private IWidget widget;
		private ArrayList<ClickListener> listeners = new ArrayList<ClickListener>();
		private ArrayList<FocusListener> focusListeners = new ArrayList<FocusListener>();
		private ArrayList<KeyboardListener> keyboardListeners = new ArrayList<KeyboardListener>();
		public void addClickListener(ClickListener listener) {
			listeners.add(listener);
		}
		public void addFocusListener(FocusListener listener) {
			focusListeners.add(listener);
		}
		public void addKeyboardListener(KeyboardListener listener) {
			keyboardListeners.add(listener);
		}
		List<ClickHandler> clickHandlerCollection = new ArrayList<ClickHandler>();
		public HandlerRegistration addClickHandler(ClickHandler handler) {
			clickHandlerCollection.add(handler);
			return null;
		}
		public void fireClick(){
			for (ClickListener clickListener : listeners) {
				clickListener.onClick(null);
			}
			for (ClickHandler clickHandler : clickHandlerCollection) {
				clickHandler.onClick(null);
			}
		}
		public void fireOnFocus(){
			for (FocusListener focusListener : focusListeners) {
				focusListener.onFocus(null);
			}
			for (FocusHandler focusHandler : focusHandlers) {
				focusHandler.onFocus(null);
			}
		}
		public void fireOnLostFocus(){
			for (FocusListener focusListener : focusListeners) {
				focusListener.onLostFocus(null);
			}
			for (BlurHandler blurHandler : blurHandlers) {
				blurHandler.onBlur(null);
			}
		}
		public int getTabIndex() {
			return 0;
		}
		public IWidget getWidget() {
			return widget;
		}
		public void removeClickListener(ClickListener listener) {
			listeners.remove(listener);
		}
		public void removeFocusListener(FocusListener listener) {
			focusListeners.remove(listener);
		}
		public void removeKeyboardListener(KeyboardListener listener) {
			keyboardListeners.remove(listener);
		}
		public void setAccessKey(char key) {
		}
		public void setFocus(boolean focused) {
		}
		public void setIWidget(IWidget widget) {
			this.widget = widget;
		}
		public void setTabIndex(int index) {
		}
		public void fireEvent(GwtEvent<?> event) {
			// TODO Auto-generated method stub
			
		}
		public HandlerRegistration addKeyDownHandler(KeyDownHandler handler) {
			// TODO Auto-generated method stub
			return null;
		}
		public HandlerRegistration addKeyPressHandler(KeyPressHandler handler) {
			// TODO Auto-generated method stub
			return null;
		}
		public HandlerRegistration addKeyUpHandler(KeyUpHandler handler) {
			// TODO Auto-generated method stub
			return null;
		}
		List<FocusHandler> focusHandlers = new ArrayList<FocusHandler>();
		List<BlurHandler> blurHandlers = new ArrayList<BlurHandler>();
		List<MouseOutHandler> mouseOutHandlers = new ArrayList<MouseOutHandler>();
		List<MouseOverHandler> mouseOverHandlers = new ArrayList<MouseOverHandler>();
		List<MouseDownHandler> mouseDownHandlers = new ArrayList<MouseDownHandler>();
		List<MouseMoveHandler> mouseMoveHandlers = new ArrayList<MouseMoveHandler>();
		List<MouseUpHandler> mouseUpHandlers = new ArrayList<MouseUpHandler>();
		public HandlerRegistration addFocusHandler(FocusHandler handler) {
			focusHandlers.add(handler);
			return null;
		}
		public HandlerRegistration addBlurHandler(BlurHandler handler) {
			blurHandlers.add(handler);
			return null;
		}
		public HandlerRegistration addMouseOverHandler(MouseOverHandler handler) {
			mouseOverHandlers.add(handler);
			return null;
		}
		public HandlerRegistration addMouseOutHandler(MouseOutHandler handler) {
			mouseOutHandlers.add(handler);
			return null;
		}
		public HandlerRegistration addMouseDownHandler(MouseDownHandler handler) {
			mouseDownHandlers.add(handler);
			return null;
		}
		public HandlerRegistration addMouseMoveHandler(MouseMoveHandler handler) {
			mouseMoveHandlers.add(handler);
			return null;
		}
		public HandlerRegistration addMouseUpHandler(MouseUpHandler handler) {
			mouseUpHandlers.add(handler);
			return null;
		}
	}
	
	public static class FocusWidgetMock extends WidgetMock implements IFocusWidget{

	ClickListenerCollection clickListenerCollection = new ClickListenerCollection();
	public void addClickListener(ClickListener listener) {
		clickListenerCollection.add(listener);
	}

	public void addKeyboardListener(KeyboardListener listener) {
		// TODO Auto-generated method stub
		
	}
	
	List<FocusHandler> focusHandlers = new ArrayList<FocusHandler>();
	List<BlurHandler> blurHandlers = new ArrayList<BlurHandler>();
	public HandlerRegistration addFocusHandler(FocusHandler handler) {
		focusHandlers.add(handler);
		return null;
	}
	public HandlerRegistration addBlurHandler(BlurHandler handler) {
		blurHandlers.add(handler);
		return null;
	}
	
	List<ClickHandler> clickHandlerCollection = new ArrayList<ClickHandler>();
	public HandlerRegistration addClickHandler(ClickHandler handler) {
		clickHandlerCollection.add(handler);
		return null;
	}
	public void fireClick(){
		clickListenerCollection.fireClick(null);
		for (ClickHandler clickHandler : clickHandlerCollection) {
			clickHandler.onClick(null);
		}
	}

	public void fireOnFocus(){
		for (FocusHandler focusHandler : focusHandlers) {
			focusHandler.onFocus(null);
		}
	}
	public void fireOnLostFocus(){
		for (BlurHandler blurHandler : blurHandlers) {
			blurHandler.onBlur(null);
		}
	}
	
	public int getTabIndex() {
		// TODO Auto-generated method stub
		return 0;
	}
	
	public void removeClickListener(ClickListener listener) {
		clickListenerCollection.remove(listener);
	}

	public void removeKeyboardListener(KeyboardListener listener) {
		// TODO Auto-generated method stub
		
	}

	public void setAccessKey(char key) {
		// TODO Auto-generated method stub
		
	}

	public void setFocus(boolean focused) {
		// TODO Auto-generated method stub
		
	}

	public void setTabIndex(int index) {
		// TODO Auto-generated method stub
		
	}

	public void fireEvent(GwtEvent<?> event) {
		// TODO Auto-generated method stub
		
	}

	public HandlerRegistration addKeyDownHandler(KeyDownHandler handler) {
		// TODO Auto-generated method stub
		return null;
	}

	public HandlerRegistration addKeyPressHandler(KeyPressHandler handler) {
		// TODO Auto-generated method stub
		return null;
	}

	public HandlerRegistration addKeyUpHandler(KeyUpHandler handler) {
		// TODO Auto-generated method stub
		return null;
	}
	
}
	
	public static class FormPanelMock extends WidgetMock implements IFormPanel{

		boolean isSubmitted = false;
		private String url;
		
		public void addFormHandler(FormHandler handler) {
		}

		public String getAction() {
			return url;
		}
		
		public boolean isSubmitted() {
			return isSubmitted;
		}

		public boolean onFormSubmit() {
			return false;
		}

		public void onFrameLoad() {
		}

		public void removeFormHandler(FormHandler handler) {
		}

		public void setAction(String url) {
			this.url = url;
		}

		public void setEncoding(String encodingType) {
			// TODO Auto-generated method stub
			
		}

		public void setMethod(String method) {
			// TODO Auto-generated method stub
			
		}

		public void submit() {
			isSubmitted = true;
		}

		public HandlerRegistration addSubmitCompleteHandler(SubmitCompleteHandler handler) {
			return null;
		}

		public HandlerRegistration addSubmitHandler(SubmitHandler handler) {
			return null;
		}
	}
	
	public static class HiddenMock extends WidgetMock implements IHidden{
		private String value;
		private String name;

		public String getName() {
			return name;
		}

		public String getValue() {
			return value;
		}

		
		public void setName(String name) {
			this.name = name;
		}

		public void setValue(String value) {
			this.value = value;
		}
	}
	
	public static class HTMLMock extends WidgetMock implements IHTML{

		private String html;
		ClickListenerCollection clickListenerCollection = new ClickListenerCollection();
		private boolean enable = true;

		public HTMLMock() {
		}

		public HTMLMock(String html) {
			setHTML(html);
		}

		public void addClickListener(ClickListener listener) {
			clickListenerCollection.add(listener);
		}

		public void addMouseListener(MouseListener listener) {
			// TODO Auto-generated method stub
			
		}

		public void addMouseWheelListener(MouseWheelListener listener) {
			// TODO Auto-generated method stub
			
		}
		public void fireClick(){
			clickListenerCollection.fireClick(null);
			for (ClickHandler clickHandler : clickHandlers) {
				clickHandler.onClick(null);
			}
		}
		public Direction getDirection() {
			// TODO Auto-generated method stub
			return null;
		}

		public HorizontalAlignmentConstant getHorizontalAlignment() {
			// TODO Auto-generated method stub
			return null;
		}

		public String getHTML() {
			return html;
		}
		
		public String getText() {
			return html;
		}

		public boolean getWordWrap() {
			// TODO Auto-generated method stub
			return false;
		}

		public boolean isEnable() {
			return enable;
		}

		public void removeClickListener(ClickListener listener) {
			clickListenerCollection.remove(listener);
		}

		public void removeMouseListener(MouseListener listener) {
			// TODO Auto-generated method stub
			
		}

		public void removeMouseWheelListener(MouseWheelListener listener) {
			// TODO Auto-generated method stub
			
		}

		public void setDirection(Direction direction) {
			// TODO Auto-generated method stub
			
		}

		public void setEnable(boolean enable) {
			this.enable = enable;
		}

		public void setHorizontalAlignment(HorizontalAlignmentConstant align) {
			// TODO Auto-generated method stub
			
		}

		public void setHTML(String html) {
			this.html = html;
		}
		public void setText(String text) {
			html = text;
		}
		public void setWordWrap(boolean wrap) {
			// TODO Auto-generated method stub
			
		}

		List<ClickHandler> clickHandlers = new ArrayList<ClickHandler>();
		public HandlerRegistration addClickHandler(ClickHandler handler) {
			clickHandlers.add(handler);
			return null;
		}

		public void fireEvent(GwtEvent<?> event) {
			// TODO Auto-generated method stub
			
		}

		public HandlerRegistration addMouseOverHandler(MouseOverHandler handler) {
			return null;
		}

		public HandlerRegistration addMouseOutHandler(MouseOutHandler handler) {
			return null;
		}

	}
	
	public static class ImageMock extends WidgetMock implements IImage{
		ClickListenerCollection clickListenerCollection = new ClickListenerCollection();
		private String url;
		private MediaPicture mediaPicture;
		private boolean showLowResolution;
		private LoadListenerCollection loadListenerCollection = new LoadListenerCollection();
		public void addClickListener(ClickListener listener) {
			clickListenerCollection.add(listener);
		}

		public void addLoadListener(LoadListener listener) {
			loadListenerCollection.add(listener);
		}

		public void addMouseListener(MouseListener listener) {
			
		}
		
		public void addMouseWheelListener(MouseWheelListener listener) {
			// TODO Auto-generated method stub
			
		}
		
		public void fireClick(){
			clickListenerCollection.fireClick(null);
			for (ClickHandler clickHandler : clickHandlers) {
				clickHandler.onClick(null);
			}
		}

		public void fireLoad(){
			loadListenerCollection.fireLoad(null);
			for (LoadHandler loadHandler : loadHandlers) {
				loadHandler.onLoad(null);
			}
		}

		public void fireLoadError(){
			loadListenerCollection.fireError(null);
			for (ErrorHandler errorHandler : errorHandlers) {
				errorHandler.onError(null);
			}
		}

		public int getHeight() {
			return 0;
		}

		public Image getImage() {
			// TODO Auto-generated method stub
			return null;
		}

		public MediaPicture getMediaPicture() {
			return mediaPicture;
		}

		public String getUrl() {
			return url;
		}

		public int getWidth() {
			return 0;
		}

		public void removeClickListener(ClickListener listener) {
			clickListenerCollection.remove(listener);
		}

		public void removeLoadListener(LoadListener listener) {
			loadListenerCollection.remove(listener);
		}

		public void removeMouseListener(MouseListener listener) {
			// TODO Auto-generated method stub
			
		}

		public void removeMouseWheelListener(MouseWheelListener listener) {
			// TODO Auto-generated method stub
			
		}

		public void setMediaPicture(MediaPicture mediaPicture,	boolean showLowResolution) {
			this.mediaPicture = mediaPicture;
			this.showLowResolution = showLowResolution;
		}

		public void setUrl(String url) {
			this.url = url;
		}

		List<LoadHandler> loadHandlers = new ArrayList<LoadHandler>();
		public HandlerRegistration addLoadHandler(LoadHandler handler) {
			loadHandlers.add(handler);
			return null;
		}

		public void fireEvent(GwtEvent<?> event) {
		}

		List<ErrorHandler> errorHandlers = new ArrayList<ErrorHandler>();
		public HandlerRegistration addErrorHandler(ErrorHandler handler) {
			errorHandlers.add(handler);
			return null;
		}

		List<ClickHandler> clickHandlers = new ArrayList<ClickHandler>();
		public HandlerRegistration addClickHandler(ClickHandler handler) {
			clickHandlers.add(handler);
			return null;
		}

		List<MouseDownHandler> mouseDownHandlers = new ArrayList<MouseDownHandler>();
		public HandlerRegistration addMouseDownHandler(MouseDownHandler handler) {
			mouseDownHandlers.add(handler);
			return null;
		}

		List<MouseUpHandler> mouseUpHandlers = new ArrayList<MouseUpHandler>();
		public HandlerRegistration addMouseUpHandler(MouseUpHandler handler) {
			mouseUpHandlers.add(handler);
			return null;
		}

		List<MouseOutHandler> mouseOutHandlers = new ArrayList<MouseOutHandler>();
		public HandlerRegistration addMouseOutHandler(MouseOutHandler handler) {
			mouseOutHandlers.add(handler);
			return null;
		}

		List<MouseOverHandler> mouseOverHandlers = new ArrayList<MouseOverHandler>();
		public HandlerRegistration addMouseOverHandler(MouseOverHandler handler) {
			mouseOverHandlers.add(handler);
			return null;
		}

		List<MouseMoveHandler> mouseMoveHandlers = new ArrayList<MouseMoveHandler>();
		public HandlerRegistration addMouseMoveHandler(MouseMoveHandler handler) {
			mouseMoveHandlers.add(handler);
			return null;
		}

		List<MouseWheelHandler> mouseWheelHandlers = new ArrayList<MouseWheelHandler>();
		public HandlerRegistration addMouseWheelHandler(MouseWheelHandler handler) {
			mouseWheelHandlers.add(handler);
			return null;
		}

		public void setTitle(String title) {
		}

	}
	
	public static class JsUtilMock implements IJsUtil{

		public void addCommand(Command incrementalCommand) {
			incrementalCommand.execute();
		}
		public void addCommand(IncrementalCommand incrementalCommand) {
			while(incrementalCommand.execute()){
				
			}
		}
		Map<String, String> cookies = new HashMap<String, String>();
		List<EventPreview> eventListeners = new ArrayList<EventPreview>();
		public void addCookie(String cookieName, String value) {
			cookies.put(cookieName, value);
		}
		public void addEventPreview(EventPreview eventListener) {
			eventListeners.add(eventListener);
		}
		public void addWindowResizeListener(WindowResizeListener windowResizeListener) {
		}
		public void addWindowScrollListener(WindowScrollListener windowScrollListener) {
		}
		public void cancelCurrentEvent() {
		}
		public boolean containsEventPreview(EventPreview eventPreview){
			return eventListeners.contains(eventPreview);
		}
		public String format(double number, String pattern) {
			return ((int)number)+"";
		}
		public int getClientHeight() {
			return 0;
		}
		public int getClientWidth() {
			return 0;
		}
		public String getCookie(String name) {
			return cookies.get(name);
		}

		public String getDomainUrl() {
			return "beta.homeprodigy.com";
		}

		public String getHref() {
			return null;
		}

		public String getInfoFromDiv(String divId) {
			return null;
		}

		public int getScrollLeft() {
			// TODO Auto-generated method stub
			return 0;
		}

		public int getScrollTop() {
			// TODO Auto-generated method stub
			return 0;
		}

		public String gup(String name) {
			// TODO Auto-generated method stub
			return null;
		}

		public String gup(String url, String string) {
			// TODO Auto-generated method stub
			return null;
		}

		public boolean isGalleryPage() {
			// TODO Auto-generated method stub
			return false;
		}

		public boolean isIphoneUserAgent() {
			// TODO Auto-generated method stub
			return false;
		}

		public boolean isMapPage() {
			// TODO Auto-generated method stub
			return false;
		}

		public boolean isNotTemplateSite() {
			// TODO Auto-generated method stub
			return false;
		}

		public boolean isPropertyDetailsPage() {
			// TODO Auto-generated method stub
			return false;
		}

		public boolean isWwwSite() {
			// TODO Auto-generated method stub
			return false;
		}

		public String md5(String lurl) {
			// TODO Auto-generated method stub
			return null;
		}

		public void open(String url, String name, String features, int top,
				int left) {
			// TODO Auto-generated method stub
			
		}

		public void openWindow(String url, String name, String features) {
			// TODO Auto-generated method stub
			
		}

		public void removeEventPreview(EventPreview eventListener) {
			eventListeners.remove(eventListener);
		}

		public void setLocation(String url) {
			// TODO Auto-generated method stub
			
		}
		public void setPrintableImageUrl(IWidget widget, String url) {
			// TODO Auto-generated method stub
			
		}
		public void setStyleAttribute(IWidget widget, String name, String value) {
			// TODO Auto-generated method stub
			
		}
		public void showAlert(String text) {
			// TODO Auto-generated method stub
			
		}
		public void trackUrchinHit(String pageName) {
			// TODO Auto-generated method stub
			
		}
		public String getUserAgentId() {
			// TODO Auto-generated method stub
			return null;
		}
		public String getUserCity() {
			// TODO Auto-generated method stub
			return null;
		}
		public Integer getUserCustId() {
			// TODO Auto-generated method stub
			return null;
		}
		public String getUserEmail() {
			// TODO Auto-generated method stub
			return null;
		}
		public Integer getUserId() {
			// TODO Auto-generated method stub
			return null;
		}
		public String getUserIp() {
			// TODO Auto-generated method stub
			return null;
		}
		public Float getUserLat() {
			// TODO Auto-generated method stub
			return null;
		}
		public Float getUserLng() {
			// TODO Auto-generated method stub
			return null;
		}
		public String getUserName() {
			// TODO Auto-generated method stub
			return null;
		}
		public String getUserState() {
			// TODO Auto-generated method stub
			return null;
		}
		public String getUserTempId() {
			// TODO Auto-generated method stub
			return null;
		}
		public String getUserType() {
			// TODO Auto-generated method stub
			return null;
		}
		public String getUserTypeVerified() {
			// TODO Auto-generated method stub
			return null;
		}
		public String getUserUri() {
			// TODO Auto-generated method stub
			return null;
		}
		public boolean isUserTypeVerified(String userTypeVerified) {
			// TODO Auto-generated method stub
			return false;
		}
		public Request sendRequest(String url, int method,
				RequestCallback requestCallback) {
			// TODO Auto-generated method stub
			return null;
		}
		public String encodeComponent(String arrayAsString) {
			return arrayAsString;
		}
		public void sendRequest(int requestId, String url,
				ResponseHandler handler) {
			// TODO Auto-generated method stub
			
		}
		public boolean isIe6() {
			// TODO Auto-generated method stub
			return false;
		}
		public void addEventPreviewHander(NativePreviewHandler handler) {
			// TODO Auto-generated method stub
			
		}
		public boolean isAccountValidationPage() {
			// TODO Auto-generated method stub
			return false;
		}
		public boolean isLoginPage() {
			// TODO Auto-generated method stub
			return false;
		}
		public void addWindowResizeHandler(ResizeHandler handler) {
			// TODO Auto-generated method stub
			
		}
		public void trackGAVar(String varName) {
			// TODO Auto-generated method stub
			
		}
		public void removeCookie(String name) {
			cookies.remove(name);
		}
		public void addWindowScrollHandler(ScrollHandler handler) {
		}
		public void trackEvent(String category, String action, String optionalLabel, String optionalValue) {
		}
		public void trackEvent(String category, String action, String optionalLabel) {
		}
		public void trackEvent(String category, String action) {
		}
		
	}
	
	public static class LazyWidgetMock extends WidgetMock implements ILazyWidget{
		List<WidgetListener> listeners = new ArrayList<WidgetListener>();
		public void addWidgetListener(WidgetListener widgetListener) {
			listeners.add(widgetListener);
		}
		public void fireOnAttach(){
			for (WidgetListener listener : listeners) {
				listener.onAttach(this);
			}
		}
		public void fireOnInit(){
			for (WidgetListener listener : listeners) {
				listener.onInit(this);
			}
		}
		public void removeWidgetListener(WidgetListener widgetListener) {
			listeners.remove(widgetListener);
		}
	}
	
	public static class ListBoxMock extends FocusWidgetMock implements IListBox{

		private List<String> items;
		private List<String> values;
		private int selectedIndex;
		private String selectedItem;
		private ChangeListenerCollection changeListeners = new ChangeListenerCollection();
		private String name;

		public void addChangeListener(ChangeListener listener) {
			changeListeners.add(listener);
		}

		public void fireOnChange() {
			changeListeners.fireChange(null);
			for (ChangeHandler changeHandler : changeHandlers) {
				changeHandler.onChange(null);
			}
		}

		public String getItemText(int index) {
			return items != null ? items.get(index) : null;
		}

		public String getName() {
			return name;
		}

		public int getSelectedIndex() {
			return selectedIndex;
		}

		public String getSelectedItem() {
			return selectedItem;
		}

		public String getSelectedValue() {
			return selectedItem;
		}

		public void removeChangeListener(ChangeListener listener) {
			changeListeners.remove(listener);
		}

		public void setItems(List<String> items, List<String> values) {
			this.items = items;
			this.values = values;
		}

		public void setName(String name) {
			this.name = name;
		}
		public void setSelectedIndex(int selectedIndex) {
			this.selectedIndex = selectedIndex;
		}

		public void setSelectedItem(String selectedItem) {
			this.selectedItem = selectedItem;
		}

		public void setItems(List<String> items) {
			this.items = items;
		}

		List<ChangeHandler> changeHandlers = new ArrayList<ChangeHandler>();
		public HandlerRegistration addChangeHandler(ChangeHandler handler) {
			changeHandlers.add(handler);
			return null;
		}

		public int getItemCount() {
			return 0;
		}

		public String getValue(int index) {
			return null;
		}

	}
	
	public static class IndexedPanelMock extends PanelMock implements IIndexedPanel{

		public int getWidgetCount() {
			return widgets.size();
		}

		public Widget getWidget(int index) {
			return null;
		}

		public int getWidgetIndex(Widget child) {
			return 0;
		}

		public boolean remove(int index) {
			return false;
		}
		
	}
	public static class PanelMock extends WidgetMock implements IPanel{
		protected List<IWidget> widgets = new ArrayList<IWidget>();

		public void add(IWidget widget) {
			widgets.add(widget);
		}

		public void add(Widget w) {
		}

		public void clear() {
		}

		public Iterator<Widget> iterator() {
			return null;
		}

		public boolean remove(Widget w) {
			return widgets.remove(w);
		}
	}

	public static class PopupWidgetMock extends WidgetMock implements IPopupWidget{

		public void addPopupListener(PopupListener popupListener) {
		}
		public void hide() {
			setVisible(false);
		}
		public void removePopupListener(PopupListener popupListener) {
		}
		public void setWidget(IWidget widget) {
		}
		public void show(int x, int y) {
			setVisible(true);
		}
	}
	
	public static class PrefilledTextInputMock extends TextInputMock implements PrefilledTextInput{
		private String defaultText;

		public String getDefaultText() {
			return defaultText;
		}
		public void setDefaultText(String defaultText) {
			this.defaultText = defaultText;
		}
		public void showDefaultText() {
			setText(defaultText);
		}
	}
	
	public static class ScrollPanelMock extends SimplePanelMock implements IScrollPanel{

		private int scrollPosition;
		ScrollListenerCollection scrollListenerCollection = new ScrollListenerCollection();

		public void addScrollListener(ScrollListener listener) {
			scrollListenerCollection.add(listener);
		}
		public void fireScroll(){
			scrollListenerCollection.fireScroll(null, 0, 0);
		}
		public int getScrollPosition() {
			return scrollPosition;
		}

		public void removeScrollListener(ScrollListener listener) {
			scrollListenerCollection.remove(listener);
		}
		
		public void setScrollPosition(int scrollPosition) {
			int oldScrollPosition = this.scrollPosition;
			this.scrollPosition = scrollPosition;
			if(oldScrollPosition != scrollPosition)
				fireScroll();
		}
	}
	
	public static class SimplePanelMock extends WidgetMock implements ISimplePanel{

		private IWidget widget;

		public void add(IWidget widget) {
			
		}

		public void add(Widget w) {
		}

		public void clear() {
		}

		public IWidget getIWidget() {
			return widget;
		}

		public Widget getWidget() {
			throw new UnsupportedOperationException("use getIWidget() instead");
		}

		public Iterator<Widget> iterator() {
			return null;
		}

		public boolean remove(Widget w) {
			return false;
		}

		public void setWidget(IWidget widget) {
			this.widget = widget;
		}
	}
	

	public static class TextInputMock extends WidgetMock implements TextInput{
		private String text;
		private boolean enabled;

		public void addChangeListener(ChangeListener listener) {
		}
		public void addClickListener(ClickListener listener) {
			// TODO Auto-generated method stub
			
		}
		List<ClickHandler> clickHandlerCollection = new ArrayList<ClickHandler>();
		public HandlerRegistration addClickHandler(ClickHandler handler) {
			clickHandlerCollection.add(handler);
			return null;
		}
		public void fireClick(){
			for (ClickHandler clickHandler : clickHandlerCollection) {
				clickHandler.onClick(null);
			}
		}
		
		public void addKeyboardListener(KeyboardListener listener) {
			// TODO Auto-generated method stub
			
		}

		public void fireFocus(){
			for (FocusHandler focusHandler : focusHandlers) {
				focusHandler.onFocus(null);
			}
		}

		public void fireLostFocus(){
			for (BlurHandler blurHandler : blurHandlers) {
				blurHandler.onBlur(null);
			}
		}

		public String getName() {
			// TODO Auto-generated method stub
			return null;
		}

		public int getTabIndex() {
			// TODO Auto-generated method stub
			return 0;
		}

		public String getText() {
			return text;
		}

		public boolean isAttached() {
			// TODO Auto-generated method stub
			return false;
		}
		public boolean isEnabled() {
			return enabled;
		}
		public void removeChangeListener(ChangeListener listener) {
		}

		public void removeClickListener(ClickListener listener) {
			// TODO Auto-generated method stub
			
		}

		public void removeKeyboardListener(KeyboardListener listener) {
			// TODO Auto-generated method stub
			
		}

		public void selectAll() {
			// TODO Auto-generated method stub
			
		}

		public void setAccessKey(char key) {
			// TODO Auto-generated method stub
			
		}
		public void setCursorPos(int pos) {
			// TODO Auto-generated method stub
			
		}
		public void setEnabled(boolean enabled) {
			this.enabled = enabled;
		}
		public void setFocus(boolean focused) {
			// TODO Auto-generated method stub
			
		}
		public void setName(String name) {
			// TODO Auto-generated method stub
			
		}
		public void setTabIndex(int index) {
			// TODO Auto-generated method stub
			
		}
		public void setText(String text) {
			this.text = text;
		}
		public void fireEvent(GwtEvent<?> event) {
			// TODO Auto-generated method stub
			
		}
		public HandlerRegistration addKeyDownHandler(KeyDownHandler handler) {
			// TODO Auto-generated method stub
			return null;
		}
		public HandlerRegistration addKeyPressHandler(KeyPressHandler handler) {
			// TODO Auto-generated method stub
			return null;
		}
		public HandlerRegistration addKeyUpHandler(KeyUpHandler handler) {
			// TODO Auto-generated method stub
			return null;
		}
		List<FocusHandler> focusHandlers = new ArrayList<FocusHandler>();
		List<BlurHandler> blurHandlers = new ArrayList<BlurHandler>();
		public HandlerRegistration addFocusHandler(FocusHandler handler) {
			focusHandlers.add(handler);
			return null;
		}
		public HandlerRegistration addBlurHandler(BlurHandler handler) {
			blurHandlers.add(handler);
			return null;
		}
		
		public HandlerRegistration addChangeHandler(ChangeHandler handler) {
			// TODO Auto-generated method stub
			return null;
		}
	}
	
	public static class TimerMock extends Timer implements ITimer{
		private Command command;
		public void cancel() {
		}
		public void schedule(int i) {
			command.execute();
		}
		public void scheduleRepeating(int ms) {
			command.execute();
		}
		public void setCommand(Command command) {
			this.command = command;
		}
	}

	public static class SelectionInputMock extends WidgetMock implements SelectionInput{

		private boolean checked;
		private boolean enable;
		private String name;
		private String html;
		private String text;

		public boolean isChecked() {
			return checked;
		}

		public boolean isEnabled() {
			return enable;
		}

		public void setChecked(boolean checked) {
			this.checked = checked;
		}

		public void setEnabled(boolean enable) {
			this.enable = enable;
		}

		public String getName() {
			return name;
		}

		public void setName(String name) {
			this.name = name;
		}

		public String getHTML() {
			return html;
		}

		public void setHTML(String html) {
			this.html = html;
		}

		public String getText() {
			return text;
		}

		public void setText(String text) {
			this.text = text;
		}

		public HandlerRegistration addClickHandler(ClickHandler handler) {
			return null;
		}

		public void fireEvent(GwtEvent<?> event) {
		}

		public HandlerRegistration addKeyDownHandler(KeyDownHandler handler) {
			return null;
		}

		public HandlerRegistration addKeyPressHandler(KeyPressHandler handler) {
			return null;
		}

		public HandlerRegistration addKeyUpHandler(KeyUpHandler handler) {
			return null;
		}

		public HandlerRegistration addFocusHandler(FocusHandler handler) {
			return null;
		}

		public HandlerRegistration addBlurHandler(BlurHandler handler) {
			return null;
		}

		public int getTabIndex() {
			return 0;
		}

		public void setAccessKey(char key) {
		}

		public void setFocus(boolean focused) {
		}

		public void setTabIndex(int index) {
		}
		
	}
	
	public static class WidgetMock implements IWidget{

		private boolean visible = true;
		private String height;
		private String width;
		private boolean isAttached;

		String styleName = "";

		private UIObject parent;

		public void addStyleDependentName(String styleName) {
			this.styleName = this.styleName + " " + this.styleName+"-"+styleName;
		}

		public void addStyleName(String styleName) {
			this.styleName = this.styleName + " " + styleName;
			this.styleName = this.styleName.trim();
		}

		public int getAbsoluteLeft() {
			return 0;
		}

		public int getAbsoluteTop() {
			return 0;
		}

		public int getOffsetHeight() {
			if(height != null && height.indexOf("px") != -1)
				return new Integer(height.substring(0, height.indexOf("px")));
			return 0;
		}

		public int getOffsetWidth() {
			if(width != null && width.indexOf("px") != -1)
				return new Integer(width.substring(0, width.indexOf("px")));
			return 0;
		}

		public UIObject getParent() {
			return parent;
		}
		public String getStyleName() {
			return styleName;
		}
		public boolean isAttached() {
			return isAttached;
		}
		public boolean isVisible() {
			return visible;
		}
		public void removeFromParent() {
			parent = null;
		}
		public void removeStyleName(String styleName) {
			this.styleName = this.styleName.replaceAll(styleName, "");
		}
		public void setAttached(boolean isAttached) {
			this.isAttached = isAttached;
		}
		public void setHeight(String height) {
			this.height = height;
		}

		public void setParent(UIObject parent) {
			this.parent = parent;
		}


		public void setSize(String width, String height) {
			this.width = width;
			this.height = height;
		}

		public void setStyleName(String styleName) {
			this.styleName = styleName;
		}

		public void setVisible(boolean visible) {
			this.visible = visible;
		}
		
		public void setWidth(String width) {
			this.width = width;
		}

		public void setPixelSize(int width, int height) {
			this.width = width+"px";
			this.height = height+"px";
		}
	}

}
